package com.clkj.cldisabledmanclient.mvp;

import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

import com.clkj.cldisabledmanclient.R;
import com.clkj.cldisabledmanclient.base.BaseActivity;
import com.clkj.cldisabledmanclient.constant.ShareKey;
import com.clkj.cldisabledmanclient.mvp.login.ActivityLogin;
import com.clkj.cldisabledmanclient.mvp.main.ActivityMain;
import com.clkj.cldisabledmanclient.util.CommonUtil;

/**
 * Created by Administrator on 2017/7/27.
 */

public class ActivityWelcome extends BaseActivity {

    private ImageView ivWelcome;


    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.activity_welcome);

        ivWelcome = (ImageView) findViewById(R.id.iv_welcome);

        Animation animation = AnimationUtils.loadAnimation(ActivityWelcome.this, R.anim.splash);
        ivWelcome.startAnimation(animation);

        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {

                String loginTag = (String) CommonUtil.getShareValue(ShareKey.LOGIN_TAG, "false");
                if ("true".equals(loginTag)) {
                    startActivity(new Intent(ActivityWelcome.this, ActivityMain.class));
                } else {
                    startActivity(new Intent(ActivityWelcome.this, ActivityLogin.class));
                }
                finish();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
    }

    @Override
    public void initData() {

    }

    @Override
    public void assignView() {

    }

    @Override
    public void initView() {

    }

    CountDownTimer welcomeCountTimer = new CountDownTimer(1500, 1000) {
        @Override
        public void onTick(long millisUntilFinished) {

        }

        @Override
        public void onFinish() {
            startActivity(new Intent(ActivityWelcome.this, ActivityMain.class));
        }
    };
}
